package com.ybkj.o2o.zhuanche.controller.v4;

import com.ybkj.o2o.zhuanche.manager.CarManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * Created by Administrator on 2016/12/23.
 */
@Controller("carResV4")
@RequestMapping("api/car/v4")
public class CarRes {

    
  @Autowired
  private CarManager carManager;


  /**
   * 导入车辆.
   */
  @RequestMapping(value = "batchCreate", method = RequestMethod.POST)
  @ResponseBody
  public ResultTransport batchCreate(
      @RequestParam("cars") String cars,
      @RequestParam("appKey") String appKey) {
    try {
      Map<String,Object> map = carManager.batchCreate(cars,appKey);
      ResultTransport instance = ResultTransport.getErrorBy(ErrorConstantV4.SUCCESS);
      instance.setData(map);
      return instance;
    } catch (Exception ex) {
      ex.printStackTrace();
      return ResultTransport.getErrorBy(ErrorConstantV4.SERVER_ERROR);
    }
  }
}
